package org.snusmumr.android.media.data.adapter;

import java.util.List;

import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

class CheckListener implements OnCheckedChangeListener {
	private int position;
	private List<Integer> selected;

	public CheckListener(int position, List<Integer> selected) {
		super();
		this.position = position;
		this.selected = selected;
	}

	@Override
	public void onCheckedChanged(CompoundButton buttonView,
			boolean isChecked) {
		
		if(isChecked) {
			if(! selected.contains((Object) position))
				selected.add(position);
		} else {
			selected.remove((Object)position);
		}
		onChecked(isChecked, position, selected.size());
	}
	
	public void onChecked(boolean isChecked, int position, int checkedCount) {}
}